package com.turbo.cloud.core.annotations.dict.aspects;

import com.turbo.cloud.core.annotations.dict.annotations.DictTranslateExecute;
import com.turbo.cloud.core.annotations.dict.processor.TranslateProcessor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * @author zhangluning
 */
@Slf4j
@Order
@RequiredArgsConstructor
@Aspect
@Component
public class DictTranslateAspect {

    @Around("@annotation(translationExecute)")
    public Object translationExecuteHandler(ProceedingJoinPoint joinPoint, DictTranslateExecute translationExecute) throws Throwable {
        Object result = joinPoint.proceed();
        TranslateProcessor.process(result, translationExecute.beanClass(), translationExecute.field());
        return result;
    }

}
